package cn.sciento.farm.devicemanager.service.impl;

import cn.sciento.farm.devicemanager.dao.entity.DevSceneDeviceRel;
import cn.sciento.farm.devicemanager.dao.mapper.SceneDeviceRelMapper;
import cn.sciento.farm.devicemanager.service.SceneDeviceRelService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SceneDeviceRelServiceImpl implements SceneDeviceRelService {

    @Autowired
    SceneDeviceRelMapper sceneDeviceRelMapper;

    @Override
    public int deleteBySceneId(Long id) {
        QueryWrapper queryWrapper = new QueryWrapper<DevSceneDeviceRel>();
        queryWrapper.eq("scene_id",id);
        return sceneDeviceRelMapper.delete(queryWrapper);
    }

    @Override
    public int insert(DevSceneDeviceRel deviceSceneRel) {
        return sceneDeviceRelMapper.insert(deviceSceneRel);
    }

    @Override
    public List<DevSceneDeviceRel> getBySceneId(Long id) {
        QueryWrapper queryWrapper = new QueryWrapper<DevSceneDeviceRel>();
        queryWrapper.eq("scene_id",id);
        return sceneDeviceRelMapper.selectList(queryWrapper);
    }
}
